package com.yugao.fintech.antelope.infra.weixin.mp.controller.news;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yugao.fintech.antelope.infra.weixin.mp.model.rqrs.MpDraftPageReq;
import com.yugao.fintech.antelope.infra.weixin.mp.service.MpDraftService;
import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft;
import me.chanjar.weixin.mp.bean.draft.WxMpDraftItem;
import org.springframework.validation.annotation.Validated;


@Api(tags = "管理后台-公众号草稿箱")
@RestController
@RequestMapping("/mpDraft")
@Validated
public class MpDraftController {
    @Autowired
    private MpDraftService mpDraftService;

    @ApiOperation(value = "分页-公众号草稿箱-图文")
    @RamResource(action = "weixin:mpDraft:query", name = "分页公众号素材-图文", type = ActionType.READ)
    @PostMapping("/pageDraft")
    public Resp<IPage<WxMpDraftItem>> pageDraft(@Validated MpDraftPageReq query) {
        return Resp.ok();
    }

    @ApiOperation(value = "保存-公众号草稿箱-图文")
    @RamResource(action = "weixin:mpMaterialNews:save", name = "保存公众号素材-图文", type = ActionType.WRITE)
    @PostMapping("/saveDraft")
    public Resp<?> saveDraft(@RequestBody WxMpAddDraft wxMpAddDraft) {
        mpDraftService.saveDraft(wxMpAddDraft);
        return Resp.ok();
    }
}
